import request from '@/utils/request'

// [获取 - 文章分类]
export const artGetChannelsService = () => {
  return request.get('/my/cate/list')
}

// [增加 - 文章分类]
export const artAddChannelsService = ({ cate_name, cate_alias }) => {
  return request.post('/my/cate/add', {
    cate_name,
    cate_alias
  })
}

// [更新 - 文章分类]
export const artEditChannelsService = ({ id, cate_name, cate_alias }) => {
  return request.put('/my/cate/info', {
    id,
    cate_name,
    cate_alias
  })
}

// [删除 - 文章分类]
export const artDelChannelsService = (id) => {
  return request.delete('/my/cate/del', {
    params: {
      id
    }
  })
}

// [获取 - 文章列表]
export const artGetArticlesService = ({
  pagenum,
  pagesize,
  cate_id,
  state
}) => {
  return request.get('/my/article/list', {
    params: {
      pagenum,
      pagesize,
      cate_id,
      state
    }
  })
}

// [发布 - 文章]
// 注：接口为 formData 参数时，不能写具体参数，一个 data 就行，否则数据接收不到(比如input值)
export const artLaunchArticlesService = (data) => {
  return request.post('/my/article/add', data)
}

// [获取 - 文章详情] 用于编辑文章回显
export const artGetDetailsService = (id) => {
  return request.get('/my/article/info', {
    params: {
      id
    }
  })
}

// [更新 - 文章详情] 用于编辑文章(接口参数为 formData 对象)
export const artEditArticlesService = (data) => {
  return request.put('/my/article/info', data)
}

// [删除 - 文章]
export const artDelArticlesService = (id) => {
  return request.delete('/my/article/info', {
    params: {
      id
    }
  })
}
